#include "matte.h"
#include "../core/memory.h"
#include "../core/intersection.h"
#include "../core/texture.h"

BSDF *Matte::GetBSDF(const Intersection &isect) const {
	// Do bump mapping if necessary.
	if(bumpMap)
		Bump(bumpMap, isect);
	// Alloc Memory for BSDF
	BSDF *bsdf = BSDF_ALLOC(BSDF)(isect);
	// Evaluate textures for material
	Spectrum r = Kd->Evaluate(isect);
	float sig = Clamp(sigma->Evaluate(isect), 0.f, 90.f);
	if(sig == 0.0f)
		bsdf->Add(BSDF_ALLOC(Lambertian)(r));
	else
		bsdf->Add(BSDF_ALLOC(OrenNayar)(r, sig));
	return bsdf;
}